﻿using CURE.Handler;
using CUREBusinessLogicLayer.Harmful;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CURE.Experiment
{
    public partial class ExpApproval : System.Web.UI.Page
    {
        #region 分页变量，与UI绑定
        private int numPerPage;
        /// <summary>
        /// 每页显示的条数
        /// </summary>
        public int NumPerPage
        {
            get
            {
                int temp = Convert.ToInt32(Request.Form["numPerPage"]);
                return temp == 0 ? 20 : temp;
            }
            set { numPerPage = value; }
        }
        private int pageNumShown = 10;
        /// <summary>
        /// 页数导航的个数
        /// </summary>
        public int PageNumShown
        {
            get { return pageNumShown; }
            set { pageNumShown = value; }
        }
        private int pageNum;
        /// <summary>
        /// 当前显示的页数
        /// </summary>
        public int PageNum
        {
            get
            {
                int temp = Convert.ToInt32(Request.Form["pageNum"]);
                return temp == 0 ? 1 : temp;
            }
            set { pageNum = value; }
        }
        private int totalCount;
        /// <summary>
        /// 总条数
        /// </summary>
        public int TotalCount
        {
            get { return totalCount; }
            set { totalCount = value; }
        }
        #endregion

        private string fid;

        public string Fid
        {
            get { return fid; }
            set { fid = value; }
        }

        LedgerBll leBll = new LedgerBll();

        protected void Page_Load(object sender, EventArgs e)
        {
            JudgeAuthority ja = new JudgeAuthority();
            if (ja.JudgeUserAuthorityByGroupId("Experiment/ExpList.aspx"))
            {
                fid = Request.Form["fid"];

                BindData();
            }
            else
            {
                Response.Write("<script language=javascript>top.location.href='../../Login.aspx';</script>");
                Response.End();
            }
        }

        /// <summary>
        /// 绑定用户数据
        /// </summary>
        protected void BindData()
        {
            IDictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("fid", fid);
            
            dic.Add("state", "1");
            dic.Add("HSTATE", "4");
            int totalPageCount;
            DataSet ds = leBll.GetExpListF(dic, PageNum, NumPerPage, out totalCount, out totalPageCount);
            if (ds != null)
            {

                reptMaster.DataSource = ds;
                reptMaster.DataBind();
            }
        }
    }
}